# Importing Data
BAHRAIN<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Aluminium/Aluminium.xlsx",sheet = "Sheet1", range = "E1:E264")

# Checking the Imported Data
View(BAHRAIN)
# Creating Time Series Data
BAHRAIN_ts <- ts(BAHRAIN, start=c(1998,1), end=c(2018,12), frequency=12)
# Viewing and Checking the Created Time Series Data
BAHRAIN_ts
sum(is.na(BAHRAIN_ts))
library(forecast)
BAHRAIN_ts <- tsclean(BAHRAIN_ts)
BAHRAIN_ts

# Identification: Plotting the Time Series Data
plot(BAHRAIN_ts)

# Estimating the appropriate model
BAHRAIN_ts_model <- auto.arima(BAHRAIN_ts)
BAHRAIN_ts_model

# Forecasting
options(max.print=1000000)
BAHRAIN_ts_forecast <- forecast (BAHRAIN_ts_model, level=c(95), h=364)
plot(BAHRAIN_ts_forecast)
BAHRAIN_ts_forecast             

# Exporting
write.table(BAHRAIN_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Aluminium/BAHRAIN_TSA.csv", sep=",")
